import { USER_ACTION, SET_USER, GET_USER, STORAGE_USER } from '@/utils/Const';
import Storage from '@/utils/Storage';

export default {
	namespaced : true,
	state : {
		value : Storage.get(STORAGE_USER, 1) || {}
	},
	getters : {
		[GET_USER] (state) {
			return state.value;
		}
	},
	mutations : {
		[SET_USER] (state, payload) {
			state.value = payload;
			Storage.set(STORAGE_USER, payload, 1);
		}
	},
	actions : {
		[USER_ACTION] ({ commit }, payload) {
			commit(SET_USER, payload);
		}
	}
};
